package com.xiaozhi.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * 通知实体类
 * 用于存储和管理系统通知信息
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("notifications")
public class Notification {

    /**
     * 通知ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 接收用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 通知类型
     * SYSTEM: 系统通知
     * APPOINTMENT: 预约通知
     * HEALTH: 健康提醒
     * CHAT: 聊天消息
     * ANALYSIS: 分析报告
     * SYMPTOM: 症状评估
     * REMINDER: 用药提醒
     * EMERGENCY: 紧急通知
     */
    @TableField("type")
    private String type;

    /**
     * 通知标题
     */
    @TableField("title")
    private String title;

    /**
     * 通知内容
     */
    @TableField("content")
    private String content;

    /**
     * 通知数据（JSON格式）
     * 存储与通知相关的额外数据
     */
    @TableField("data")
    private String data;

    /**
     * 通知优先级
     * LOW: 低优先级
     * NORMAL: 普通优先级
     * HIGH: 高优先级
     * URGENT: 紧急
     */
    @TableField("priority")
    private String priority;

    /**
     * 通知状态
     * PENDING: 待发送
     * SENT: 已发送
     * READ: 已读
     * FAILED: 发送失败
     */
    @TableField("status")
    private String status;

    /**
     * 是否已读
     */
    @TableField("is_read")
    private Boolean isRead;

    /**
     * 阅读时间
     */
    @TableField("read_at")
    private LocalDateTime readAt;

    /**
     * 发送时间
     */
    @TableField("sent_at")
    private LocalDateTime sentAt;

    /**
     * 计划发送时间
     */
    @TableField("scheduled_at")
    private LocalDateTime scheduledAt;

    /**
     * 过期时间
     */
    @TableField("expires_at")
    private LocalDateTime expiresAt;

    /**
     * 通知渠道
     * WEB: 网页通知
     * EMAIL: 邮件通知
     * SMS: 短信通知
     * PUSH: 推送通知
     */
    @TableField("channel")
    private String channel;

    /**
     * 关联对象类型
     * 如：appointment, health_record, chat_session等
     */
    @TableField("related_type")
    private String relatedType;

    /**
     * 关联对象ID
     */
    @TableField("related_id")
    private Long relatedId;

    /**
     * 点击跳转URL
     */
    @TableField("action_url")
    private String actionUrl;

    /**
     * 重试次数
     */
    @TableField("retry_count")
    private Integer retryCount;

    /**
     * 最大重试次数
     */
    @TableField("max_retries")
    private Integer maxRetries;

    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    /**
     * 创建者ID
     */
    @TableField(value = "created_by", fill = FieldFill.INSERT)
    private Long createdBy;

    /**
     * 更新者ID
     */
    @TableField(value = "updated_by", fill = FieldFill.INSERT_UPDATE)
    private Long updatedBy;

    /**
     * 逻辑删除标志
     */
    @TableLogic
    @TableField("deleted")
    private Boolean deleted;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @TableField("version")
    private Integer version;

    // 手动添加getter和setter方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public Notification setUserId(Long userId) {
        this.userId = userId;
        return this;
    }

    public String getType() {
        return type;
    }

    public Notification setType(String type) {
        this.type = type;
        return this;
    }

    public String getTitle() {
        return title;
    }

    public Notification setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getContent() {
        return content;
    }

    public Notification setContent(String content) {
        this.content = content;
        return this;
    }

    public String getData() {
        return data;
    }

    public Notification setData(String data) {
        this.data = data;
        return this;
    }

    public String getPriority() {
        return priority;
    }

    public Notification setPriority(String priority) {
        this.priority = priority;
        return this;
    }

    public String getStatus() {
        return status;
    }

    public Notification setStatus(String status) {
        this.status = status;
        return this;
    }

    public Boolean getIsRead() {
        return isRead;
    }

    public Notification setIsRead(Boolean isRead) {
        this.isRead = isRead;
        return this;
    }

    public LocalDateTime getReadAt() {
        return readAt;
    }

    public Notification setReadAt(LocalDateTime readAt) {
        this.readAt = readAt;
        return this;
    }

    public LocalDateTime getSentAt() {
        return sentAt;
    }

    public void setSentAt(LocalDateTime sentAt) {
        this.sentAt = sentAt;
    }

    public LocalDateTime getScheduledAt() {
        return scheduledAt;
    }

    public Notification setScheduledAt(LocalDateTime scheduledAt) {
        this.scheduledAt = scheduledAt;
        return this;
    }

    public LocalDateTime getExpiresAt() {
        return expiresAt;
    }

    public void setExpiresAt(LocalDateTime expiresAt) {
        this.expiresAt = expiresAt;
    }

    public String getChannel() {
        return channel;
    }

    public Notification setChannel(String channel) {
        this.channel = channel;
        return this;
    }

    public String getRelatedType() {
        return relatedType;
    }

    public Notification setRelatedType(String relatedType) {
        this.relatedType = relatedType;
        return this;
    }

    public Long getRelatedId() {
        return relatedId;
    }

    public Notification setRelatedId(Long relatedId) {
        this.relatedId = relatedId;
        return this;
    }

    public String getActionUrl() {
        return actionUrl;
    }

    public Notification setActionUrl(String actionUrl) {
        this.actionUrl = actionUrl;
        return this;
    }

    public Integer getRetryCount() {
        return retryCount;
    }

    public Notification setRetryCount(Integer retryCount) {
        this.retryCount = retryCount;
        return this;
    }

    public Integer getMaxRetries() {
        return maxRetries;
    }

    public void setMaxRetries(Integer maxRetries) {
        this.maxRetries = maxRetries;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public Notification setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
        return this;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public Notification setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
        return this;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public Notification setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
        return this;
    }

    public Long getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Long createdBy) {
        this.createdBy = createdBy;
    }

    public Long getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(Long updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }
}